from model.data_utils import CoNLLDataset
from model.ner_model import NERModel
from model.configner import ConfigNer
import os
import shutil
def main():
    # create instance of config
    config = ConfigNer()

    # build model
    model = NERModel(config)
    model.build()
    # model.restore_session("tmp/model.weights/") # optional, restore weights

    # create datasets
    dev   = CoNLLDataset(config.filename_dev, config.processing_word,
                         config.processing_tag, config.max_iter)
    train = CoNLLDataset(config.filename_train, config.processing_word,
                         config.processing_tag, config.max_iter)

    if os.path.isdir(config.result_path):
        shutil.rmtree(config.result_path)
    os.mkdir(config.result_path)
    # train model
    model.train(train, dev)

if __name__ == "__main__":
    main()
